using System;
using System.IO;
using System.Reflection;

using UnityEngine;

namespace Parse.Internal
{
    public class AppInformation
    {
        /// <summary>
        /// The version number of the application.
        /// </summary>
        public static string Build
        {
            get => Application.version; // unity override
        }
        /// <summary>
        /// The version number of the application.
        /// </summary>
        public static string Version
        {
            get =>
        Application.version; // unity override
        }
        // TODO: Verify if this means Parse appId or just a unique identifier.

        /// <summary>
        /// The identifier of the application
        /// </summary>
        public static string Identifier => AppDomain.CurrentDomain.FriendlyName;

        /// <summary>
        /// The name of the current application.
        /// </summary>
        public static string Name
        {
            get =>
            Application.productName; // unity override
        }
        /// <summary>
        /// The name of the current application.
        /// </summary>
        public static string CompanyName
        {
            get =>
            Application.companyName; // unity override
        }
        internal static Version ParseVersion => new AssemblyName(typeof(ParseClient).GetTypeInfo().Assembly.FullName).Version;

        /// <summary>
        /// The base path to parse caching folder location
        /// </summary>
        public static string BasePath =>
            Application.persistentDataPath;



        public static string GetRelativeStorageFallbackPath(bool isFallback, string identifier)
        {
            return Path.Combine("Parse", isFallback ? "_fallback" : "_global", $"{(isFallback ? new System.Random { }.Next().ToString() : identifier)}.cachefile");
        }


        public static event Action ProcessExit
        {
            add { Application.quitting += value; }
            remove { Application.quitting -= value; }
        }


    }

}
